/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package credit.paysystem;

import Modelo.Usuario;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

/**
 * FXML Controller class
 *
 * @author Grnmnd
 */
public class PrincipalController implements Initializable {

    @FXML
    private Pane prncpl;
    @FXML
    private MenuItem carreras;
    @FXML
    private MenuItem movi;
    @FXML
    private MenuItem usua;
    @FXML
    private MenuItem produ;
    @FXML
    private MenuItem membres;
    @FXML
    private MenuItem pass;
    @FXML
    private MenuItem recar;
    @FXML
    private MenuItem trens;
    @FXML
    private MenuItem cobro;
    static Usuario Autoriza;
    
    @FXML
    public void cerrarsesion (ActionEvent e) throws IOException {
        prncpl.getScene().getWindow().hide();
        Stage stage = new Stage();
        Parent root = FXMLLoader.load(getClass().getResource("LogIn.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();
    }

    @FXML
    public void carrera(ActionEvent e) throws IOException {
        Stage stage = new Stage();
        Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();

    }

    @FXML
    public void movimientos(ActionEvent e) throws IOException {
        Stage stage = new Stage();
        Parent root = FXMLLoader.load(getClass().getResource("Movimientos.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();

    }

    @FXML
    public void usuario(ActionEvent e) throws IOException {
        Stage stage = new Stage();
        Parent root = FXMLLoader.load(getClass().getResource("Usuarios.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();

        
    }

    @FXML
    public void producto(ActionEvent e) throws IOException {
        Stage stage = new Stage();
        Parent root = FXMLLoader.load(getClass().getResource("Productos.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();
    }
    
    @FXML
    public void membresias(ActionEvent e) throws IOException {
        Stage stage = new Stage();
        Parent root = FXMLLoader.load(getClass().getResource("Membresias.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();
    }

    @FXML
    public void Pass(ActionEvent e) throws IOException {
        Stage stage = new Stage();
        Parent root = FXMLLoader.load(getClass().getResource("Usuarios.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        
        stage.show();

    }

    @FXML
    public void recarga(ActionEvent e) throws IOException {
        Stage stage = new Stage();
        Parent root = FXMLLoader.load(getClass().getResource("Movimientos.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();
    }

    @FXML
    public void transferencia(ActionEvent e) throws IOException {
        Stage stage = new Stage();
        Parent root = FXMLLoader.load(getClass().getResource("Movimientos.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();
    }

    @FXML
    public void cobro(ActionEvent e) throws IOException {
        Stage stage = new Stage();
        Parent root = FXMLLoader.load(getClass().getResource("cobro.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();
    }

    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        switch (Autoriza.getIdPerfil().getId()) {
            case 1:
                System.out.println("Alumno");
                trens.setVisible(true);
                pass.setVisible(true);
                break;
            case 3:
                System.out.println("Biblioteca");
                cobro.setVisible(true);
                pass.setVisible(true);
                break;
            case 4:
                System.out.println("Finanzas");
                recar.setVisible(true);
                produ.setVisible(true);
                usua.setVisible(true);
                break;
            case 5:
                System.out.println("Administrator");
                usua.setVisible(true);
                produ.setVisible(true);
                movi.setVisible(true);
                carreras.setVisible(true);
                membres.setVisible(true);
                break;

        }

    }
}
